Skip to content

fix(studio): hoist the draft-envelope reader and strip read decorations at every consumer - #8211

Merged
os-justin merged 1 commit into
mainfrom
claude/issue-8181-draft-envelope-read-decoration-strip
Sep 7, 2026
Merged

fix(studio): hoist the draft-envelope reader and strip read decorations at every consumer#8211
os-justin merged 1 commit into
mainfrom
claude/issue-8181-draft-envelope-read-decoration-strip

Conversation

@os-justin

@os-justin os-justin commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Part of objectui#8181. Draft on purpose — the PM lands it.

Deliverable 1 first: the measurement the card deliberately did not claim

The card established only "no strip is present at these sites". It did not establish whether a
decorated body reaches a gate or a write. Measured before any code was written, and the population was
re-derived rather than taken from the card — it turned out to be ten readers, not four.

# reader stripped? reaches a client gate? reaches a write?
1 views/metadata-admin/ResourceEditPage.tsx extractDraftBody yes, objectui#7603 / PR #8182 yes — the only validateMetadataDraft caller yes
2 views/studio-design/StudioDesignSurface.tsx extractDraftBody (4 call sites) no no yes — app / leaf / object / flow, each save(..., mode draft)
3 views/studio-design/PackageOwdOverviewPanel.tsx extractDraftBody (2 call sites) no no yes, unconditionally
4 views/studio-design/ObjectHooksPanel.tsx draftBody no no yes — body to hooks to editor draft to save('hook')
5 views/metadata-admin/PermissionMatrixEditor.tsx inline unwrap no no yes, failure arm only
6 views/runtime-metadata-persistence.ts unwrapDraftBody — the card's unmeasured lead no. It mirrors the missing strip too. no yes, indirectly, via RuntimeDraftBar resume
7 preview/DraftChangesPanel.tsx unwrapItemon nobody's list no n/a no, and it is still the live defect (below)
8 preview/capabilityLint.ts inline unwrapon nobody's list no advisory only no
9 preview/securityPostureLint.ts inline unwrapon nobody's list no advisory only no
10 packages/data-objectstack/src/index.ts unwrapViewDraftdifferent package, on nobody's list no no yesupdateView merges then save('view')

No gate is reached

validateMetadataDraft( and hasClientValidator( each have exactly one production call site in the
whole repo, both in ResourceEditPage, which PR #8182 already fixed. On the PM's stated criterion —
re-grade to p2 the moment a decorated body is shown reaching a gate — the answer is no.

A write IS reached, at five sites, on the success path

…and the write does not fail today only because the server launders it. saveMetaItem calls
stripReadDecorations(request.item) at the top of the method, with a comment saying it is placed first
so "the destructive-change diff, the schema gate, the authoring gate and the persisted body all see the
same document" (objectstack#4326). PUT /meta/TYPE/NAME hands the body straight to it. So: no 400.

That is a mitigation on the far side of the wire, not a licence. Measured against the bundled spec
17.2.0, for every type these sites write:

type          bare body    + read decorations                          after stripReadDecorations
object        ACCEPT       REJECT  unrecognized_keys ["_diagnostics","_draft"]   ACCEPT
app           ACCEPT       REJECT  unrecognized_keys ["_diagnostics","_draft"]   ACCEPT
flow          ACCEPT       REJECT  unrecognized_keys ["_diagnostics","_draft"]   ACCEPT
hook          ACCEPT       REJECT  unrecognized_keys ["_diagnostics","_draft"]   ACCEPT
permission    ACCEPT       REJECT  unrecognized_keys ["_diagnostics","_draft"]   ACCEPT
page          ACCEPT       REJECT  unrecognized_keys ["_diagnostics","_draft"]   ACCEPT

(view is absent because I could not build a fixture its union accepts, not because it behaves
differently — its bare body already REJECTs, so the leg does not isolate. Stated rather than papered over.)

One site IS a live, user-visible defect — and it is site 7, which nobody had listed

DraftChangesPanel fetches each entry twice, published then state=draft, and computeChangeDetail
reports every top-level key whose value differs. The framework decorates those two reads
asymmetrically: inside getMetaItem, the draft branch stamps _draft: true on the row before
decorateMetadataItem runs, and the published branch stamps nothing. So the pending-changes sheet
listed _draft under "Also changed:" on every entry that has a published counterpart, with
_diagnostics alongside whenever the two read-time verdicts differed.

A framework-internal key rendered to the author as one of their own edits, on the screen where they
decide whether to publish. No failure arm, no schema gate, no rare path — wrong on the happy path,
every time.

⚠️ I checked _packageId as a candidate second asymmetry and disproved it: getMetaItem stamps it
on both branches, and it is deliberately not a read decoration (the closed schemas declare it), so it
must not be stripped and it does not pollute the diff.

Two sites measured NOT to matter

validateSecurityPosture and validateCapabilityReferences return byte-identical findings with and
without decorations. Control that fires: an object with no sharingModel produces
error security-owd-unset in both directions, so the rules really ran. Stripped anyway — see below.

The fix: one reader, not ten strips

Zone 3's framing is right, and the measurement supports it: this is not "N consumers forgot". One
helper was copy-pasted and only one copy learned the rule. Adding a tenth strip leaves the eleventh copy
free to omit it.

extractDraftBody now lives in @object-ui/data-objectstack — beside the getDraft whose envelope it
decodes, because the unwrap is part of that method's contract, not a detail of any one view. The four
byte-identical strict copies (rows 1-4) were deleted and now import it; getDraft's own docblock points
at it and says not to hand .item to a gate or a write yourself.

Rows 5-10 keep their own presence semantics and gain the spec strip. Their tolerance is load-bearing,
not defensive
, and the split is principled rather than arbitrary: unwrapDraftBody and
unwrapViewDraft are fed by MetadataClient.get(), which already unwrapped the envelope
(objectui#4271), so the bare-body limb is their normal path. They split on which client method feeds
them
, not on what they mean — and all of them strip now.

Rows 8-9 were fixed despite measuring clean, deliberately: the alternative is leaving two more verbatim
copies of the unwrap that omit the rule, which is exactly the shape this card exists to end. The comment
there says so, including that it is defence in depth and not a fix.

The reusable asset is the spec's exported stripReadDecorations, exactly as #8182 used it. No second
hand-maintained key list. No schema loosened. No gate taught to tolerate _diagnostics. The presence
verdict still runs before the strip, so removing our own annotations can never turn a served draft
into "nothing pending", and the ADR-0010 protection envelope (_lock, _provenance, _packageId,
_packageVersion) is untouched because the closed schemas declare it.

Clause-2: does this fire on the accept/reject leg?

Yes, and on the same leg as #8182 — but at a different door. #8182's leg was a client gate that
began accepting bodies it previously rejected. Here:

  • The publish-review diff flips its verdict, which is this PR's accept/reject leg. Before: _draft
    reported as a changed key on every entry. After: reported only when the author actually changed
    something. The pin still reports nothing at all when only the decorations differ moves the sheet
    from Also changed: _diagnostics, _draft to No differences detected.
  • The write side does not flip a verdict today, and I am saying so plainly rather than claiming a
    400 that does not happen: the server's ingress strip absorbs it. The leg that fires there is the
    spec's accept/reject verdict on the body this client emits, measured in the table above.

Tests

New / extended, all reddened by ablation:

  • packages/data-objectstack/src/draft-envelope.test.ts — the hoisted reader: strips both decorations,
    keeps the ADR-0010 envelope, does not mutate the response, and a draft carrying only decorations
    still reads as pending ({}, truthy) rather than null.
  • packages/app-shell/src/preview/__tests__/DraftChangesPanel.readDecorationStrip.test.tsx — the live
    defect. Drives the real panel through real fetch routes. Control: a genuine label change must still
    be reported, so the absences mean something.
  • packages/app-shell/src/views/studio-design/PackageOwdOverviewPanel.readDecorationStrip.test.tsx
    proves the hoist reaches a write, through the real component's real save.
  • packages/data-objectstack/src/updateView.draft.test.ts — the adapter's read-edit-write round trip.
  • packages/app-shell/src/views/runtime-metadata-persistence.test.ts — both limbs of the tolerant sibling.

Ablation

Mutated all five strip sites (removing the strip, keeping the unwrap), proved the mutation reached disk
with anchored grep -c before/after — five markers, zero strips left — ran the pins, restored with
git checkout HEAD -- PATH, and proved the restore by state: git hash-object equals
git rev-parse HEAD:PATH for all four files, git diff HEAD empty, git status empty. The script
carries trap RESTORE EXIT INT TERM with absolute paths.

Test Files  5 failed (5)
     Tests  11 failed | 37 passed (48)

Every new assertion fails without the strip; the 37 pre-existing assertions in those files still pass,
which is what shows the mutation was surgical.

Verification runs

Both changed packages were run in full — 1108 test files, 10798 tests, zero failures.

run result
vitest packages/data-objectstack/ + app-shell/{preview,views,services} 468 files, 4669 passed, 1 skipped
vitest packages/app-shell/ (everything else in the package) 640 files, 6129 passed, 1 skipped
type-check both packages (after building app-shell's closure) 0 TS errors
turbo run lint both packages exit 0, 0 errors
eslint . --no-inline-config repo-wide, 4399 files 9 error-severity findings inside my files, every one blamed to another commit — pre-existing, and main exits 1 on this command too
check: control-bytes, unreferenced-sources, phantom-deps, self-import, vi-mock-specifiers, vi-mock-inherit, handler-key-reads, governed-queue-guard, docs-route-closure, pre-install-import-graph, side-effects-array, esm-specifiers, spec-symbols, i18n-keys, i18n-drift, i18n-dead-keys, lint:coverage all exit 0
check:changeset-presence, check:changeset-no-major exit 0
check:readme-exports, check:eager-closure, check:spec-floors NOT MEASURED — each printed a prerequisite refusal ("no build output to judge" / "run pnpm build first"), not a verdict. Declared to CI. readme-exports judges README-to-exports, so adding an export cannot break it.

Declared narrowings, so review can see exactly what was and was not run here:

  1. turbo ls --affected names 34 packages; the 32 transitive ones are reached only through
    data-objectstack, whose exported surface delta is a pure addition (extractDraftBody) — no
    existing export changed shape, and unwrapDraftBody is not re-exported from app-shell's public
    index. Their suites are CI's.
  2. The ablation run itself was taken out of the shared verify lock after two consecutive
    exit 99 queue timeouts (a sibling held it 582s). It is five small test files, mutating only my own
    worktree, so nothing cross-agent depended on serialising it.

⚠️ Shared-box courtesy note for whoever schedules the next batch: the full app-shell run held the verify
lock 17m44s and the wrapper filed holder-side starvation against it. Splitting app-shell's suite would
help the queue.

Also worth the reviewer's eye

objectui#7612switch the sharing_rule edit-door client gate on — is filed and open, and its
recorded blocker was the _diagnostics ingress. #8182 closed that at the gate's own call site and this
PR closes it at the remaining nine. No new card filed; the existing one is simply unblocked. ⛔ Not
addressed here.

This PR deliberately carries no auto-close directive: objectui#8181 stays open until the PM decides
the grade, because the measurement above may move it.

Attribution, in prose because the footer block does not survive a body PATCH intact: generated by
Claude Code, session session_01YBWFb5YgMU5dw8p2VKj16S.

…ns at every consumer

`client.getDraft()` serves a DECORATED body: the draft branch stamps
`_draft: true` and `decorateMetadataItem` attaches `_diagnostics` for any type
with a registered Zod schema. The spec names both READ-TIME decorations because
a served body is not a valid input to the schema that produced it until they
come off (`METADATA_READ_DECORATIONS`).

objectui#7603 taught ONE site to strip. It could only teach one, because
`extractDraftBody` was implemented four times (three verbatim copies plus a
hand-rolled one in ObjectHooksPanel) and six more consumers unwrapped the
envelope inline. Ten readers, one of which knew the rule. Adding a tenth strip
would leave the eleventh copy free to omit it, so the reader is hoisted instead:
`extractDraftBody` now lives in `@object-ui/data-objectstack`, beside the
`getDraft` whose envelope it decodes.

Measured, per site, before writing anything:

  - The publish-review diff is the LIVE half. `DraftChangesPanel` compares the
    published body against the draft body key by key, and the framework
    decorates those two reads asymmetrically -- only the draft branch stamps
    `_draft`. So the sheet listed `_draft` under "Also changed:" on every entry
    with a published counterpart, with `_diagnostics` alongside whenever the two
    read-time verdicts differed: framework-internal keys shown to the author as
    their own edits, on the screen where they decide whether to publish.
  - Six sites merge a decorated body into a document they write back through
    `save(..., { mode: 'draft' })`. Today's server absorbs that -- `saveMetaItem`
    strips read decorations on ingress, before its own schema gate -- so nothing
    400s. That is a mitigation on the far side of the wire, not a licence for
    this client to emit a body its own spec calls invalid.
  - No CLIENT validation gate is reached: `validateMetadataDraft` has exactly
    one caller, and objectui#7603 already fixed it.
  - The two preview lints do not move their verdict on a decorated body
    (control: an object with no `sharingModel` fires `security-owd-unset` in
    both directions). Stripped anyway, so no verbatim copy of the unwrap is left
    behind without the rule.

The key list is the spec's exported `stripReadDecorations`, never a second
hand-maintained copy here. The presence verdict still runs BEFORE the strip, so
removing our own annotations can never turn a served draft into "nothing
pending". The ADR-0010 protection envelope (`_lock`, `_provenance`,
`_packageId`, `_packageVersion`) is deliberately untouched: the closed schemas
declare those keys. No schema was loosened and no gate was taught to tolerate
`_diagnostics`.

Refs: objectui#8181

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 50 chunks) 3189.7 KB 3191.4 KB
Main entry chunk (gzip) 143.9 KB 350 KB
Entry file index-B3vw1vMF.js
Status PASS

The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it.


📦 Bundle Size Report

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 15.67KB 5.75KB
app-shell (runtime-config.js) 20.68KB 7.36KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.06KB 3.86KB
auth (ActiveOrganizationStorage.js) 25.05KB 9.16KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.18KB 10.59KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.15KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.65KB 2.22KB
auth (SocialSignInButtons.js) 9.61KB 3.89KB
auth (UserMenu.js) 3.41KB 1.23KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.21KB 10.80KB
auth (createAuthenticatedFetch.js) 8.46KB 3.43KB
auth (index.js) 3.19KB 1.44KB
auth (invitation-status.js) 1.22KB 0.70KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 5.13KB 2.35KB
collaboration (CommentThread.js) 26.08KB 7.56KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 498.00KB 113.91KB
core (index.js) 6.96KB 2.79KB
create-plugin (index.js) 10.08KB 3.26KB
data-objectstack (index.js) 189.11KB 52.55KB
fields (index.js) 243.04KB 61.36KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (builtinAggregateLabels.js) 0.86KB 0.49KB
i18n (currency.js) 1.22KB 0.64KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 6.57KB 2.76KB
i18n (index.js) 3.65KB 1.47KB
i18n (pickLocalized.js) 7.62KB 3.26KB
i18n (provider.js) 26.89KB 9.04KB
i18n (useDisplayLocale.js) 2.85KB 1.45KB
i18n (useObjectLabel.js) 34.34KB 9.17KB
i18n (useSafeTranslation.js) 5.60KB 2.33KB
layout (index.js) 38.84KB 10.94KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.75KB
mobile (index.js) 1.99KB 0.87KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.72KB 0.42KB
mobile (useSpecGesture.js) 4.39KB 1.66KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 11.71KB 4.29KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 6.24KB 2.16KB
permissions (discardProofCache.js) 1.04KB 0.55KB
permissions (evaluator.js) 5.12KB 1.74KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 4.83KB 2.27KB
plugin-ai (index.js) 15.16KB 3.68KB
plugin-calendar (index.js) 47.67KB 13.25KB
plugin-charts (index.js) 70.62KB 19.71KB
plugin-chatbot (index.js) 193.54KB 46.04KB
plugin-dashboard (index.js) 131.41KB 34.43KB
plugin-designer (index.js) 211.51KB 43.01KB
plugin-detail (index.js) 247.68KB 63.49KB
plugin-editor (index.js) 2.23KB 1.05KB
plugin-form (index.js) 131.01KB 32.32KB
plugin-gantt (index.js) 167.16KB 40.99KB
plugin-grid (index.js) 208.58KB 56.63KB
plugin-kanban (index.js) 52.83KB 14.63KB
plugin-list (index.js) 113.35KB 27.73KB
plugin-map (index.js) 20.49KB 6.83KB
plugin-markdown (index.js) 13.88KB 4.80KB
plugin-report (index.js) 43.42KB 11.92KB
plugin-timeline (index.js) 30.10KB 8.74KB
plugin-tree (index.js) 9.33KB 3.25KB
plugin-view (index.js) 84.46KB 20.80KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.66KB 3.50KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 81.07KB 26.86KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.63KB 2.18KB
react (schema-input.js) 2.32KB 1.24KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 6.58KB 2.74KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 5.55KB 2.45KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 20.57KB 5.88KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 13.64KB 4.59KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 1.00KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 2.74KB 1.41KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (expression.js) 0.20KB 0.18KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 4.74KB 2.25KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 4.73KB 2.28KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (select-option.js) 0.20KB 0.19KB
types (spec-report.js) 5.05KB 1.93KB
types (spec-ui-namespace.js) 0.20KB 0.19KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
types (ui-action.js) 8.11KB 3.32KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants